#pragma once

typedef struct Vertex
{
	D3DXVECTOR3 position;
	D3DCOLOR color;
} Vertex;

class App
{
public:
	App(void);
	~App(void);

	bool Initialize(HWND windowHandle);
	bool Dispose(void);

private:
	LPDIRECT3D9 pD3D_; // DirectX interface

#pragma region Device

private:
	LPDIRECT3DDEVICE9 device_; // DirectX device
	bool CreateDevice(HWND windowHandle);

#pragma endregion

public:
	bool CreateVertexDeclaration(void);
	bool CreateVertexBuffer(UINT vertexCount);
	bool SetVertexBuffer(UINT vertexCount, Vertex vertices[]);
	bool CreateIndexBuffer(unsigned int indexCount);
	bool SetIndexBuffer(unsigned int indexCount, short indices[]);

private:
	LPDIRECT3DVERTEXDECLARATION9 vertexDeclaration_;
	LPDIRECT3DVERTEXBUFFER9 vertexBuffer_;
	LPDIRECT3DINDEXBUFFER9 indexBuffer_;

public:
	bool CreateShader(void);

private:
	LPD3DXEFFECT shader_;
	D3DXHANDLE worldViewProjHandle_;

public:
	void InitMatrices(void);

private:
	D3DXMATRIX world_;
	D3DXMATRIX view_;
	D3DXMATRIX proj_;
	D3DXMATRIX worldViewProj_;

public:
	void RenderFrame(D3DPRIMITIVETYPE primitiveType, UINT vertexCount, UINT primitiveCount);
};

